Skip to content

feat(DynamicElement): add OnTouchStart/End parameter#7898

Merged
ArgoZhang merged 10 commits intomainfrom
revert-event
Apr 20, 2026
Merged

feat(DynamicElement): add OnTouchStart/End parameter#7898
ArgoZhang merged 10 commits intomainfrom
revert-event

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Apr 20, 2026

Link issues

fixes #7897

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Simplify event handling and disposal for dynamic elements, select inputs, and buttons by reverting custom async disposal logic and using standard Blazor primitives.

Enhancements:

  • Remove IAsyncDisposable implementation and custom async disposal logic from DynamicElement in favor of simpler component lifetime management.
  • Simplify Select component change handling by binding the input directly to OnChange, removing the cached EventCallback field and its custom disposal.
  • Render Select dropdown items with plain div elements instead of DynamicElement to reduce complexity and dependencies.
  • Relax ButtonBase disposal behavior by no longer clearing click-related callbacks explicitly, while preserving async submit button unregistration.

Copilot AI review requested due to automatic review settings April 20, 2026 06:17
@bb-auto bb-auto Bot added the chore This are tasks or bot action label Apr 20, 2026
@bb-auto bb-auto Bot added this to the v10.5.0 milestone Apr 20, 2026
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Apr 20, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reverts async disposal and DynamicElement usage introduced previously, simplifying component lifecycles and event handling in DynamicElement, Select, and ButtonBase, and restoring direct HTML elements and callbacks in Select.

Sequence diagram for Select onchange handling after revert

sequenceDiagram
    actor User
    participant Browser
    participant SelectComponent as Select~TValue~

    User->>Browser: Edit text in input
    User->>Browser: Move focus / confirm
    Browser->>SelectComponent: onchange event
    activate SelectComponent
    SelectComponent->>SelectComponent: OnChange(ChangeEventArgs args)
    SelectComponent->>SelectComponent: GetRowsByItems()
    SelectComponent->>SelectComponent: GetItemWithEnumValue()
    SelectComponent->>SelectComponent: GetCurrentSelectItem()
    SelectComponent->>SelectComponent: SelectedItemChanged(SelectedItem item)
    SelectComponent-->>Browser: Render updated selected text
    deactivate SelectComponent
Loading

Class diagram for reverted disposal and event handling changes

classDiagram
    class BootstrapComponentBase
    class SimpleSelectBase~TValue~
    class DynamicElement {
    }
    class ButtonBase {
        bool IsAsync
        void RegisterEvents()
        protected ValueTask DisposeAsync(bool disposing)
    }
    class Select~TValue~ {
        string _defaultVirtualizedItemText
        SelectedItem SelectedItem
        SelectedItem SelectedRow
        void OnParametersSet()
        Task OnClickItem(SelectedItem item)
        Task SelectedItemChanged(SelectedItem item)
        Task OnChange(ChangeEventArgs args)
        SelectedItem GetCurrentSelectItem()
    }

    BootstrapComponentBase <|-- DynamicElement
    BootstrapComponentBase <|-- ButtonBase
    SimpleSelectBase~TValue~ <|-- Select~TValue~

    %% Key reverted aspects represented structurally:
    %% - DynamicElement no longer implements IAsyncDisposable
    %% - Select~TValue~ no longer defines a _onChangeEventCallback field
    %% - Select~TValue~ no longer overrides DisposeAsync(bool disposing)
    %% - ButtonBase.DisposeAsync no longer clears click callbacks but still handles async button unregistering
Loading

File-Level Changes

Change Details Files
Remove IAsyncDisposable implementation and async dispose logic from DynamicElement and dependent components.
  • Drop IAsyncDisposable from DynamicElement and remove its DisposeAsync methods that nulled event handlers and ChildContent.
  • Remove Select component override of DisposeAsync that only reset a cached EventCallback.
  • Simplify ButtonBase.DisposeAsync by removing cleanup of click callbacks while retaining async submit button unregistration.
src/BootstrapBlazor/Components/BaseComponents/DynamicElement.cs
src/BootstrapBlazor/Components/Select/Select.razor.cs
src/BootstrapBlazor/Components/Button/ButtonBase.cs
Simplify Select component rendering and event wiring by removing DynamicElement usage and cached EventCallback.
  • Delete the private _onChangeEventCallback field and associated initialization in OnParametersSet.
  • Wire the input @onchange directly to OnChange in the razor markup instead of using a cached EventCallback.
  • Replace DynamicElement in the item template with a plain div using @OnClick for item selection.
  • Minor whitespace/BOM adjustment at top of Select.razor.
src/BootstrapBlazor/Components/Select/Select.razor.cs
src/BootstrapBlazor/Components/Select/Select.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#7897 Remove the IAsyncDisposable/DisposeAsync implementation from DynamicElement (revert implementing IDisposeAsync/IAsyncDisposable on this class).
#7897 Revert related changes in components that depended on the DynamicElement IAsyncDisposable implementation or associated disposal patterns (e.g., Select and Button) so they no longer rely on that behavior.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f559e9e) to head (6112c4a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #7898   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          764       764           
  Lines        34213     34196   -17     
  Branches      4706      4707    +1     
=========================================
- Hits         34213     34196   -17     
Flag Coverage Δ
BB 100.00% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts a prior change that introduced async disposal patterns (IDisposeAsync/IAsyncDisposable-style cleanup) into UI components, restoring simpler component lifecycles and event wiring—primarily around DynamicElement, and related usage in Select and Button.

Changes:

  • Remove IAsyncDisposable implementation and disposal-time delegate clearing from DynamicElement.
  • Simplify Select rendering/event wiring by removing the cached EventCallback field, using direct @onchange="OnChange", and replacing DynamicElement row rendering with a plain <div>.
  • Remove disposal-time clearing of click delegates from ButtonBase.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/BootstrapBlazor/Components/Select/Select.razor.cs Removes cached EventCallback and manual StateHasChanged call; deletes DisposeAsync override used only for callback clearing.
src/BootstrapBlazor/Components/Select/Select.razor Switches editable input to direct @onchange="OnChange" and replaces DynamicElement row wrapper with a standard <div @onclick=...>.
src/BootstrapBlazor/Components/Button/ButtonBase.cs Removes disposal-time nulling/emptying of click delegates.
src/BootstrapBlazor/Components/BaseComponents/DynamicElement.cs Reverts IAsyncDisposable implementation and associated delegate/content clearing disposal code.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ArgoZhang ArgoZhang changed the title revert(DynamicElement): revert implement IDisposeAsync interface feat(DynamicElement): add OnTouchStart/End parameter Apr 20, 2026
@ArgoZhang ArgoZhang added enhancement New feature or request and removed chore This are tasks or bot action labels Apr 20, 2026
@ArgoZhang ArgoZhang merged commit 6db9d85 into main Apr 20, 2026
4 checks passed
@ArgoZhang ArgoZhang deleted the revert-event branch April 20, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(DynamicElement): add OnTouchStart/End parameter

2 participants